package priv.pfz.raft.verify;

import lombok.extern.slf4j.Slf4j;
import priv.pfz.raft.peer.ClusterHolder;
import priv.pfz.raft.peer.Peer;
import priv.pfz.raft.peer.PeerFactory;

import java.util.List;
import java.util.Scanner;

/**
 * Hello world!
 *
 */
@Slf4j
public class App {

    public static void main( String[] args ) {
        System.out.println( "Hello World!" );

        List<Peer> peers = PeerFactory.createPeers(3,
                20000,
                3000);
        for (Peer peer : peers) {
            ClusterHolder.peerMap.put(peer.getPeerConf().getPeerName(), peer);
        }

        for (Peer peer : peers) {
            peer.start();
        }

        Scanner in = new Scanner(System.in);
        while (true) {
            String line = in.nextLine();
            boolean exit = CommandManager.executeCmd(line);
            if (exit) {
                return;
            }
        }

        //SleepUtil.sleep(999999999);
    }
}
